.686P
.model flat, c  ;;.model flat,stdcall
 ;MessageBoxA proto stdcall,:dword,:dword,:dword,:dword
 ExitProcess proto stdcall :dword
 scanf       proto c :vararg
 printf      proto c :vararg
 ;includelib  user32.lib						;;MessageBoxA()
 includelib  kernel32.lib					;;ExitProcess()
 includelib  libcmt.lib						;;_mainCRTStartup => main
 includelib  legacy_stdio_definitions.lib	;;printf

 .data
 saved_password db "0123456789",0
 input_info db "%s",0
 input_password db "0000000000",0
 hint db "Input a password.",0
 succeed db "OK!",0
 faild db "Incorrect Password!",0

 .stack 200
 
 .code 
 main proc
 start:
 invoke printf, offset hint
 invoke scanf, offset input_info,offset input_password
 xor ebx, ebx
 L3:	; 检查长度是否相等
	cmp ebx, 0Bh
	jl L4
	jmp unmatch
 L4:
	mov al, saved_password[ebx]
	mov ah, input_password[ebx]
	inc ebx
	cmp ax, 0 ;同时结尾，相等
	je L5
	cmp ah, 0 ; input先行结尾，不相等
	jmp unmatch
	cmp al, 0 ; saved先行结尾，不相等
	jmp unmatch
	jmp L3

 L5:
 	xor ebx, ebx
 L1:
 	cmp ebx, 0Ah 
 	jl L2
 	jmp match
 L2:
 	mov al, saved_password[ebx] ; 按字节比较
 	cmp al, input_password[ebx]
 	jnz unmatch
 	inc ebx
 	jmp L1
 unmatch: ;密码不匹配
	invoke printf, offset faild
	jmp exit
 match: ;密码匹配
	invoke printf, offset succeed
	jmp exit
 exit:invoke ExitProcess, 0
 main	endp
		end

